package JSE_02.Map.Demo09;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class Demo09 {
    public static void main(String[] args){
        HashMap<Integer,String> poker=new HashMap<>();
        ArrayList<Integer> pokerIndex=new ArrayList<>(); // 用来排序
        List<String> color= List.of("♣","♠","♥","♦");
        List<String> number=List.of("2","A","K","Q","J","10","9","8","7","6","5","4","3");
        int index=0;
        poker.put(index,"大王");
        pokerIndex.add(index);
        index++;
        poker.put(1,"小王");
        pokerIndex.add(index);
        index++;
        for (String num:number){
            for(String col:color){
                poker.put(index,col+num);
                pokerIndex.add(index);
                index++;
            }
        }

        System.out.println(poker);
        System.out.println(pokerIndex);
        System.out.println("洗牌后:");
        Collections.shuffle(pokerIndex);
        System.out.println(pokerIndex);

        System.out.println("===============");
        ArrayList<Integer> palyer01=new ArrayList<>();
        ArrayList<Integer> palyer02=new ArrayList<>();
        ArrayList<Integer> palyer03=new ArrayList<>();
        ArrayList<Integer> dipai=new ArrayList<>();

        for (int i = 0; i < pokerIndex.size(); i++) {
            Integer in=pokerIndex.get(i);
            //System.out.println("in:"+in);
            if(i>=51){
                dipai.add(in);
            }else if(i%3==0){
                palyer01.add(in);
            }else if(i%3==1){
                palyer02.add(in);
            }else if(i%3==2){
                palyer03.add(in);
            }
        }

        Collections.sort(dipai);
        Collections.sort(palyer01);
        Collections.sort(palyer02);
        Collections.sort(palyer03);
        System.out.println("===========");
        System.out.println(dipai);
        System.out.println(palyer01);
        System.out.println(palyer02);
        System.out.println(palyer03);

        lookPoker("刘德华",poker,palyer01); // poker是所有的牌 palyer01拿到的索引
        lookPoker("周星驰",poker,palyer02);
        lookPoker("周润发",poker,palyer03);
        lookPoker("底牌",poker,dipai);
    }

    public static void lookPoker(String name,HashMap<Integer,String> poker,ArrayList<Integer> list){
        System.out.print(name+":");

        for(Integer key:list){
            String value=poker.get(key);
            System.out.print(value+" ");
        }
        System.out.println();
    }
}
